package com.dtspark.scala.basic

class HelloOOP(age: Int) {
  var name = "spark"
  def sayHello = println("hi     " + name + " age " + age)
}

object HelloOOP {
  var number = 0
  def main(args: Array[String]): Unit = {
    println("oop ok")

    // val helloOOP =new HelloOOP
    val helloOOP = HelloOOP(30)
    helloOOP.sayHello
    HelloOOP()
    HelloOOP(30)
    HelloOOP(30)
    HelloOOP(30)
    HelloOOP(30)
    Array(1, 2, 3, 4, 5)
    Array.apply(1, 2, 3, 4, 5)
  }

  def apply(age: Int): HelloOOP = {
    println("apply number  " + number)
    number += 1
    new HelloOOP(age)
  }

  def apply(): HelloOOP = {
    println("apply number =====   " + number)
    number += 1
    new HelloOOP(10)
  }
}